// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT

import {
    VerticalBox,
    HorizontalBox,
    Button,
    LineEdit,
} from "std-widgets.slint";
import { Webview } from "../src/webview/webview.slint";

export { WebviewLogic } from "../src/webview/webview.slint";
export { Palette } from "std-widgets.slint";

export component MyApp inherits Window {
    preferred-width: 1224px;
    preferred-height: 768px;

    VerticalBox {
        padding: 0px;
        spacing: 0px;

        HorizontalBox {
            height: 50px;
            padding: 8px;
            spacing: 8px;

            Button {
                text: "Back";
                clicked => {
                    webview.back();
                }
            }

            Button {
                text: "Forward";
                clicked => {
                    webview.forward();
                }
            }

            Button {
                text: "Reload";
                clicked => {
                    webview.reload();
                }
            }

            lineEdit := LineEdit {
                text: webview.current_url;
                horizontal-stretch: 1;
                accepted(url) => {
                    webview.loadUrl(lineEdit.text);
                }
            }

            Button {
                text: "Go";
                clicked => {
                    webview.loadUrl(lineEdit.text);
                }
            }
        }

        Rectangle {
            webview := Webview {
                width: 100%;
                height: 100%;
            }
        }
    }
}
